import axios from 'axios'

const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 600000
})

// request拦截器
service.interceptors.request.use(
  config => {
    // token 权限认证相关请求头配置
    // if (getToken()) {
    //   config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
    // }
    config.headers['Content-Type'] = 'application/json'
    return config
  },
  error => {
    Promise.reject(error)
  }
)

service.interceptors.response.use(
  response => response.data,
  error => {
    // ERROR 相关配置
    return Promise.reject(error)
  }
)

export default service
